<template>
  <div>
    <el-button v-for="button in buttons" v-bind="button" @click="handle(button.eventType)">{{ button.title }}</el-button>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { ICellRendererParams } from 'ag-grid-community';

const props = defineProps<{
  params: ICellRendererParams;
}>();

const buttons = ref(props.params.colDef.cellRendererParams);

function handle(eventType: string) {
  const onHandle = props.params.context.onHandle;
  if (!onHandle) {
    return;
  }
  onHandle(eventType, props.params.data, props.params);
}
</script>
